home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -serious- / programming / other / tandem / teaching / 63.asm < prev    next >
Assembly Source File  |  1999-09-06  |  4KB  |  174 lines

  1. * teaching/63.asm   Scrollers II, View Rastport    Version 0.01    8.6.99
  2.  
  3.  
  4.  include 'Front.i'
  5.  
  6.  
  7. port: ds.l 1               ;area to hold rastport
  8. bmap: ds.l 1               ;area to hold bitmap
  9.  
  10. rwid: dc.l 1024            ;width of rastport
  11. rhgt: dc.l 1024            ;height of rastport
  12.  
  13. rpxp: dc.l 0               ;region of rastport to be viewed
  14. rpyp: dc.l 0
  15. rpwd: dc.l 1024
  16. rpht: dc.l 1024
  17.  
  18. wdxp: ds.l 1               ;region of window where rastport is shown
  19. wdyp: ds.l 1
  20. wdwd: ds.l 1
  21. wdht: ds.l 1
  22.  
  23.  
  24. * text strings
  25. strings: dc.b 0
  26. st_1: dc.b 'View a rastport by using window scrollers',0 ;1
  27.  dc.b 'I have made a rastport, & filled it with ellipses.',0 ;2
  28.  dc.b 'After you click "OK" on this requester, use the window scrollers',0
  29.  dc.b 'to view the rastport. Also, resize, zoom & move the window.',0 ;4
  30.  dc.b 'Finally, click the window to quit.',0 ;5
  31.  dc.b 'Error: out of public memory',0 ;6
  32.  
  33.  ds.w 0
  34.  
  35.  
  36. * control program execution
  37. Program:
  38.  TLwindow #-1
  39.  beq Pr_quit
  40.  
  41.  TLwindow #0,#0,#0,#320,#100,#640,xxp_Height(a4),#-1,#st_1
  42.  beq Pr_quit
  43.  
  44.  bsr Make                  ;draw ellipses on rastport
  45.  beq Pr_quit               ;go if out of mem
  46.  TLreqinfo #2,#4,#0        ;instructions
  47.  
  48. Pr_resz:                   ;here if window resized
  49.  TLwupdate
  50.  
  51.  move.l xxp_AcWind(a4),a5  ;set sliders to top left
  52.  move.l xxp_scrl(a5),a3
  53.  moveq #0,d0
  54.  move.w xxp_PWidth(a5),d0
  55.  clr.l xxp_hztp(a3)
  56.  move.l d0,xxp_hzvs(a3)
  57.  move.l #1024,xxp_hztt(a3)
  58.  move.w xxp_PHeight(a5),d0
  59.  clr.l xxp_vttp(a3)
  60.  move.l d0,xxp_vtvs(a3)
  61.  move.l #1024,xxp_vttt(a3)
  62.  TLwscroll set
  63.  
  64. Pr_blit:                   ;here for next blit
  65.  move.l xxp_gfxb(a4),a6
  66.  move.l port,a0
  67.  move.l xxp_hztp(a3),d0
  68.  move.l xxp_vttp(a3),d1
  69.  move.l xxp_AcWind(a4),a5
  70.  move.l xxp_WPort(a5),a1
  71.  moveq #0,d2
  72.  move.w xxp_LeftEdge(a5),d2
  73.  moveq #0,d3
  74.  move.w xxp_TopEdge(a5),d3
  75.  moveq #0,d4
  76.  move.w xxp_PWidth(a5),d4
  77.  moveq #0,d5
  78.  move.w xxp_PHeight(a5),d5
  79.  move.w #$C0,d6
  80.  TLwcheck                  ;go if window resized
  81.  bne Pr_resz
  82.  jsr _LVOClipBlit(a6)
  83.  
  84. Pr_wait:                   ;wait for response
  85.  TLkeyboard
  86.  cmp.b #$98,d0
  87.  beq Pr_blit               ;update window if scroller
  88.  TLwcheck
  89.  bne Pr_resz               ;go if resized
  90.  cmp.b #$93,d0
  91.  beq.s Pr_quit             ;quit if close window
  92.  cmp.b #$80,d0
  93.  bne Pr_wait               ;continue until clicked
  94.  
  95. Pr_quit:                   ;quit, with error report if any
  96.  TLerror
  97.  rts
  98.  
  99.  
  100. * make the rastport
  101. Make:
  102.  TLbusy
  103.  clr.l xxp_errn(a4)        ;no error so far
  104.  
  105.  TLpublic #rp_SIZEOF       ;memory for rastport
  106.  move.l d0,port
  107.  beq Mk_bad1
  108.  
  109.  move.l xxp_gfxb(a4),a6    ;init rastport
  110.  move.l d0,a1
  111.  jsr _LVOInitRastPort(a6)
  112.  
  113.  TLpublic #bm_SIZEOF       ;memory for bitmap struct
  114.  move.l d0,bmap
  115.  beq Mk_bad1
  116.  
  117.  move.l d0,a0              ;init bitmap (only 1 plane)
  118.  moveq #1,d0
  119.  move.l rwid,d1
  120.  move.l rhgt,d2
  121.  jsr _LVOInitBitMap(a6)
  122.  
  123.  move.l bmap,a0            ;point rastport to bitmap
  124.  move.l port,a1
  125.  move.l a0,rp_BitMap(a1)
  126.  
  127.  TLchip #128*1024          ;memory for bitplane  (bytes per row 1024/8=128)
  128.  move.l d0,bm_Planes(a0)
  129.  beq Mk_bad2
  130.  
  131.  move.l d0,a1
  132.  move.l #128*1024,d0
  133.  moveq #1,d1
  134.  jsr _LVOBltClear(a6)
  135.  
  136.  moveq #64,d0              ;draw ellipses:   D0 = x centre
  137.  moveq #8,d2               ;d2 = x radius
  138.  bset #31,d0               ;flag solid
  139.  move.l port,a0            ;a0 = rastport
  140.  moveq #0,d4               ;use all of rastport
  141.  moveq #0,d5
  142.  move.l #1024,d6
  143.  move.l #1024,d7
  144. Mk_col:                    ;for each column
  145.  moveq #32,d1              ;d1 = y centre
  146.  bset #31,d1               ;flag use rastport
  147.  moveq #2,d3               ;d3 = y radius
  148. Mk_elps:
  149.  TLellipse d0,d1,d2,d3,d5,d5,d6,d7,a0 ;draw ellipse
  150. Mk_fwd:
  151.  addq.w #2,d3              ;bump y radius
  152.  add.w #64,d1              ;bump y centre
  153.  cmp.w #1024,d1
  154.  bcs Mk_elps               ;until column done
  155.  addq.w #8,d2              ;bump d radius
  156.  add.w #128,d0             ;bump x centre
  157.  cmp.w #1024,d0
  158.  bcs Mk_col                ;until all columns done
  159.  
  160.  bra.s Mk_done
  161.  
  162. Mk_bad1:                   ;bad 1 - out of public mem
  163.  move.w #1,xxp_errn+2(a4)
  164.  bra.s Mk_done
  165.  
  166. Mk_bad2:                   ;bad 2 - out of chip mem
  167.  move.w #2,xxp_errn+2(a4)
  168.  
  169. Mk_done:
  170.  TLunbusy
  171.  tst.l xxp_errn(a4)
  172.  eori.w #-1,CCR
  173.  rts
  174.